package com.itlong.cloud.POJO.VO.app;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;

/**
 * <desc>
 *      APP门禁云对讲VO类
 * </desc>
 *
 * @createDate 2017/11/27
 */
@Data
@NoArgsConstructor
public class AppCloudAndEntranceDeviceVO implements Serializable,Comparable<AppCloudAndEntranceDeviceVO>{
    private String deviceName;          //设备名称
    private String deviceUnique;        //设备唯一码
    private String projectId;           //项目编号
    private String protocolVersion;     //蓝牙协议版本
    private String threshold;           //开门阈值
    private String doorAuth;             //开门权限值
    private String cardNum;              //软卡号
    private String valiTime;             //有效时间
    private String position;             //排序值
    private String roomIds;               //房间id
    private String sipAccount;              //sip账号
    private String roomNum;                 //房间编号
    private String clientAccount;           // 第三方提供账号
    private Integer systemType;     //云对讲类型1linux 2android
    private String doorType;          //门禁类型 1蓝牙门禁 2云门禁 如都存在，此字段为1,2
    public void  setEntranceDeviceVO(String deviceName, String deviceUnique,
                                     String projectId, String protocolVersion,
                                     String threshold, String doorAuth, String cardNum, String valiTime,
                                     String position) {
        this.deviceName = deviceName;
        this.deviceUnique = deviceUnique;
        this.projectId = projectId;
        this.protocolVersion = protocolVersion;
        this.threshold = threshold;
        this.doorAuth = doorAuth;
        this.cardNum = cardNum;
        this.valiTime = valiTime;
        this.position = position;
    }

    public void setCloudVO(String deviceName, String deviceUnique,
                           String projectId,   String cardNum,
                           String roomIds, String valiTime,String sipAccount, String roomNum,String position,String clientAccount) {
        this.deviceName = deviceName;
        this.deviceUnique = deviceUnique;
        this.projectId = projectId;
        this.cardNum = cardNum;
        this.valiTime = valiTime;
        this.position = position;
        this.roomIds = roomIds;
        this.sipAccount = sipAccount;
        this.roomNum = roomNum;
        this.clientAccount = clientAccount;
    }

    /**
     * <desc>
     *      排序重写方法
     * </desc>
     *
     * @param o
     * @return
     * @author Jiaqi.X
     * @createDate 2017/11/28
     */
    @Override
    public int compareTo(AppCloudAndEntranceDeviceVO o) {
        if(StringUtils.isNotBlank(this.getPosition()) && StringUtils.isNotBlank(o.getPosition())){
            if(Integer.valueOf(this.getPosition()) > Integer.valueOf(o.getPosition())){
                return 1;
            }else{
                return -1;
            }
        }
        if(StringUtils.isBlank(this.getPosition())&&StringUtils.isBlank(o.getPosition())){
            return -1;
        }else if(StringUtils.isNotBlank(o.getPosition())){
            return 1;
        }else{
            return -1;
        }
    }
}
